<?php

namespace app\user\controller;

use think\Controller;
use think\Db;
use think\Session;

class Chicang extends Mycontroller
{
    //
    public function index()
    {
        $uid=Session::get('user.id');
//        var_dump($uid);die;

        $res=Db::name('chicang')->where('uid',$uid)->select();
//        var_dump($res);
        foreach ($res as $k => $v ){
            $stock=Db::name('goods')->where('stockcode',$v['stockcode'])->find();
//            var_dump($sellprice);
            $res[$k]['stock']=$stock;
            $res[$k]['yk']=sprintf('%.2f',($stock['sellprice']-$v['buyprice'])*$v['count']);
        }

//        var_dump($res);






        return view('user/chicang',['data'=>$res]);
    }

    public function jiaogedan()
    {

        $uid=Session::get('user.id');
//        var_dump($uid);die;

        $res=Db::name('order')->where('uid',$uid)->select();

//        var_dump($res);

//        $res=null;




        return view('user/jiaogedan',['data'=>$res]);
    }
}
